import http from "@/axios/index.js";
import {handleSuccess,handleError} from "@/api/index.js";

// 日志管理API
export const LogApi = {
    // 分页查询日志
    list(params) {
        return http.get('/api/log/list', { params })
            .then(res => handleSuccess(res, '查询成功'))
            .catch(err => handleError(err, '查询失败', '查询失败'))
    },

    // 获取日志详情
    detail(id) {
        return http.get(`/api/log/detail/${id}`)
            .then(res => handleSuccess(res, '获取日志详情成功'))
            .catch(err => handleError(err, '获取日志详情失败', '日志可能不存在或您没有查看权限'))
    },

    // 归档日志
    archive(id) {
        return http.put('/api/log/archive')
            .then(res => handleSuccess(res, '归档日志成功'))
            .catch(err => handleError(err, '归档日志失败', '请检查日志ID或网络连接'))
    },
    // 导出日志
    exportLogs(params) {
        return http.get('/api/log/export', { params })
            .then(res => handleSuccess(res, '导出日志成功'))
            .catch(err => handleError(err, '导出日志失败', '请检查查询条件或网络连接'))
    },

    // 获取统计报表
    statistics(params) {
        return http.get('/api/log/statistics', { params })
            .then(res => handleSuccess(res, '获取统计报表成功'))
            .catch(err => handleError(err, '获取统计报表失败', '请检查查询条件或网络连接'))
    }
};